package fr.pascal.client.ui.barre;

import com.google.gwt.activity.shared.AbstractActivity;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.user.client.ui.AcceptsOneWidget;

import fr.pascal.client.ClientFactory;
import fr.pascal.client.mvp.MainPlace;

public class BarreNavigationActivity extends AbstractActivity implements BarreNavigation.Presenter {
	
	private ClientFactory clientFactory;
	private String selectedRubrique;
	
	public BarreNavigationActivity(MainPlace place, ClientFactory clientFactory) {
		this.clientFactory = clientFactory;
		// affectation donnees metier
		selectedRubrique = place.getToken();
	}

	@Override
	public void start(AcceptsOneWidget panel, EventBus eventBus) {
		BarreNavigation barreNavigationView = clientFactory.getBarreNavigationView();
		barreNavigationView.setPresenter(this);
		// affectation donnees metier
		barreNavigationView.setSelectedRubrique(selectedRubrique);
		panel.setWidget(barreNavigationView.asWidget());
	}

	@Override
	public void goToAccueil() {
		MainPlace mainPlace = new MainPlace("1");
		clientFactory.getPlaceController().goTo(mainPlace);
	}
}
